{if $offer_cats && $item_cats && $title_offer}
    {foreach from=$item_cats item=item_cat key=catid name=offer_cat_item}
    <div class="title_text">
        {if isset($offer_cats[$catid].name)}
            <p>{$offer_cats[$catid].name}</p>
        {/if}

    </div>
    <div id="product_new">
        <ul>
            {foreach from=$item_cat item=item key=itemid name=offer_item}

                <li title="{$item.name}"  id="offer_item_{$smarty.foreach.offer_cat_item.iteration}_{$smarty.foreach.offer_item.iteration}">
                    <div>
                        {if $item.image}
                            <a href="{$item.url}">
                                <img src="{$item.image}" width="235" height="150"/>
                            </a>
                            {else}
                            <div style="background:url(style/images/no-images-35x35.gif) no-repeat center">
                                <a href="{$item.url}"><img src="style/images201005/space.gif" width="200" height="150"/></a>
                            </div>
                        {/if}
                    </div>

                    <h2 class="detail" style="position: relative;">
                      <span>
                         <a title="{$item.name}" style="color: #fff;" href="{$item.url}">
                             {$item.name|substr:0:12}
                         </a>
                      </span>
                      <span title="{$item.name}" style="position: absolute;right: 0px;">
                        <a  href="{$item.url}"><img src="{$smarty.const.FOLDER_CSS}chitiet.png"></a>
                      </span>
                    </h2>
                </li>
            {/foreach}
        </ul>
    </div>

    {/foreach}

{/if}

{if $is_admin}
    {$begin_form}
    <div style="cursor:pointer;margin:10px 0" onclick="jQuery('#admin_item_offer').toggle();"><strong>Quản lý SP Khuyến mại</strong></div>
    <div style=";margin:10px 0" id="admin_item_offer" class="hide">
        {$msg}<br/>
        <table cellpadding="5" cellspacing="0" border="0" width="100%">
            <tr>
                <td align="right"><strong>Tiêu đề:</strong></td>
                <td><input type="text" name="title_offer" value="{$title_offer}" style="width:300px"/></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td width="23%"><strong>Danh mục</strong></td>
                <td width="77%"><strong>ID sản phẩm (cách nhau bởi dấu (,) VD: 1,2,34)</strong></td>
            </tr>
            {foreach from=$item_cat_offer item=cat_offer}
                <tr>
                    <td nowrap="nowrap">
                        <b>[{$cat_offer.id}]</b> {$cat_offer.name}
                    </td>
                    <td>
                        <input type="text" name="item_cats[{$cat_offer.id}]" value="{$cat_offer.item_ids}" style="width:100%"/>
                    </td>
                </tr>
                {if $cat_offer.sub}
                    <tr>
                        <td colspan="2" class="pl15">
                            &raquo; <span style="cursor:pointer" onclick="jQuery('.cat_offer_sub_{$cat_offer.id}').toggle();">[Danh mục con]</span>
                        </td>
                    </tr>
                    {foreach from=$cat_offer.sub item=subcat_offer}
                        <tr class="cat_offer_sub_{$cat_offer.id}{if !$cat_offer.sub_display} hide{/if}">
                            <td nowrap="nowrap" class="pl15">
                                ------- <b>[{$subcat_offer.id}]</b> {$subcat_offer.name}
                            </td>
                            <td>
                                <input type="text" name="item_cats[{$subcat_offer.id}]" value="{$subcat_offer.item_ids}" style="width:100%"/>
                            </td>
                        </tr>
                    {/foreach}
                {/if}
                <tr>
                    <td colspan="2">
                        <hr/>
                    </td>
                </tr>
            {/foreach}
        </table>
        <input type="submit" name="submit" value="Cập nhật"/> <input type="submit" name="submit" value="Xóa tất cả" onclick="return confirm('Bạn có chắc chắ muốn xóa tất cả các ID không?');"/>
    </div>


    <div style="cursor:pointer;" onclick="jQuery('#AdvItemOffer_config').toggle()"><strong>Cấu hình AdvItemOffer</strong></div>
    <div id="AdvItemOffer_config" class="hide">
        <table cellpadding="4" cellspacing="0">
            <tr>
                <td>
                    Tình trạng:
                </td>
                <td>
                    <select name="status"> {$status_option}</select>
                </td>
            </tr>
            <tr>
                <td>
                    Loại hiển thị:
                </td>
                <td>
                    <select name="type">{$type_option}</select>
                </td>
            </tr>
            <tr>
                <td>
                    Url:
                </td>
                <td>
                    <input type="text" name="url" value="{$url}"/>
                </td>
            </tr>
            <tr>
                <td>
                    Upload:
                </td>
                <td>
                    <input type="file" name="banner"/> <br/>
                    <strong>Ảnh</strong> {$adv_width}x...( .gif , .jpg ); <strong>Flash</strong>   {$adv_width}x{$adv_height}... ( .swf )
                </td>
            </tr>
            <tr>
                <td>

                </td>
                <td>
                    <input type="submit" name="submit" value="Cập nhật Quảng cáo"/>
                </td>
            </tr>
        </table>
    </div>
    {$end_form}
{/if}